package com.lawfinal.controller;


import com.lawfinal.entity.Img;
import com.lawfinal.entity.Page;
import com.lawfinal.service.ImgService;
import com.lawfinal.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author KBr
 * @since 2024-05-09
 */
@RestController
@CrossOrigin("http://localhost:5173/")
@RequestMapping("/img")
public class ImgController {

      @Autowired
      private ImgService imgService;

      @RequestMapping("/list")
      public List<Img> list(){
            return imgService.list();
      }

      @RequestMapping("/add")
      public Result save(@RequestBody Img img){
            return imgService.save(img)?Result.sucess():Result.fail();
      }

      @RequestMapping("/del")
      public Result deleteById(String id){
            return imgService.removeById(id)?Result.sucess():Result.fail();
      }
}
